<script setup>
import { RouterView } from 'vue-router';
import Containhead from '@/components/containhead.vue';
import Asidlan from '@/components/asidlan.vue';
import { ref, onMounted } from 'vue';
import { useRouter } from "vue-router";
import { tokenpost } from "@/api/login.js";
import { loguser } from "@/stores/loginuserdata.js";
const loginuser = loguser()
const router = useRouter()
//搭建manner的时候，验证有无token以及token是否已经过期，决定是否跳转登录界面
onMounted(async () => {
    if (loginuser.token == undefined) {
        router.replace('/login')
    }
    try {
        const res = await tokenpost(loginuser.token)
    } catch (error) {
        if (error.response.status == 500) {
            router.replace('/login')
        }
        localStorage.removeItem('loguser')
    }
})
</script>

<template>
    <div class="common-layout">
        <el-container> 
            <el-header class="hi animate__animated animate__slideInDown">
                <Containhead></Containhead>
            </el-header>
            <el-container>
                <Asidlan class="animate__animated animate__slideInLeft"></Asidlan>
                <el-main class="animate__animated animate__fadeInUp">
                    <RouterView></RouterView>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<style scoped>
.hi {
    background-color: rgb(94, 99, 105);
    height: 6vh;
    overflow: hidden;
}

#app {
    height: 100vh;
    overflow: hidden;
}

.el-main {
    position: relative;
    height: 94vh;
    overflow: hidden;
}


.el-container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏样式 */
</style>
